package com.smmisia.common.entity.auth.convertor;

import com.smmisia.common.entity.auth.User;
import com.smmisia.common.entity.auth.UserDTO;
import com.smmisia.common.request.auth.UserRequest;
import com.smmisia.common.request.auth.UserUpdateRequest;
import com.smmisia.common.response.auth.UserResponse;
import org.mapstruct.Mapper;
import org.mapstruct.NullValueCheckStrategy;
import org.mapstruct.factory.Mappers;
import java.util.List;

/**
 * 用户转换器
 * @author smmisia
 * @date 2023/7/27
 */
@Mapper(nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
public interface UserConvertor {

    UserConvertor INSTANCE = Mappers.getMapper(UserConvertor.class);

    public static final int DEFAULT_MIN_SALE_TIME = 60;

    /**
     * 转换为VO
     *
     * @param user
     * @return
     */
    public UserResponse mapToVo(User user);

    public UserDTO mapToUserDTO(User user);

    /**
     * 转换为VOList
     *
     * @param user
     * @return
     */
    public List<UserResponse> mapToVoList(List<User> user);

    /**
     * 转换为Entity
     * @param userRequest
     * @return
     */
    public User mapToEntity(UserRequest userRequest);

    /**
     * 转换为Entity
     * @param userUpdateRequest
     * @return
     */
    public User mapToEntityByUserUpdateRequest(UserUpdateRequest userUpdateRequest);


}
